<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link href="/ajax/libs/jquery-layout/jquery.layout-latest.css" th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link href="/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css" th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>

<body class="gray-bg">
	<div class="ui-layout-west">
		<div class="main-content">
			<div class="box box-main">
				<div class="box-header">
					<div class="box-title">
						<i class="fa icon-grid"></i> 组织机构
					</div>
					<div class="box-tools pull-right">
					    <a type="button" class="btn btn-box-tool menuItem" href="#" onclick="dept()" title="管理机构"><i class="fa fa-edit"></i></a>
						<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
						<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
						<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新机构"><i class="fa fa-refresh"></i></button>
					</div>
				</div>
				<div class="ui-layout-content">
					<div id="tree" class="ztree"></div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="container-div ui-layout-center">
		<div class="row">
			
	        <div class="btn-group hidden-xs" id="toolbar" role="group">
	        		<a class="btn btn-outline btn-success" onclick="javascript:showDetail()" shiro:hasPermission="module:cloudCpe:add">
				<i class="fa fa-info"></i> 详情
			</a>
		
			<a class="btn btn-outline btn-success" onclick="javascript:addPop()">
				<i class="fa fa-edit"></i> 编辑pop信息
			</a>
			<a class="btn btn-outline btn-success" onclick="javascript:editQos()" >
				<i class="fa fa-edit"></i> 编辑Qos信息
			</a>
			<a class="btn btn-outline btn-success" onclick="javascript:editWifi()">
				<i class="fa fa-edit"></i> 编辑Wifi信息
			</a>
			<a class="btn btn-outline btn-success" onclick="javascript:addLan()">
				<i class="fa fa-edit"></i> 编辑Lan信息
			</a>
			<a class="btn btn-outline btn-success" onclick="javascript:addRoute()" shiro:hasPermission="module:cloudCpe:add">
				<i class="fa fa-edit"></i> 编辑业务路由
			</a>
	        </div>
	        
	        <div class="col-sm-12 select-info order-table">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
	<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
	<script th:inline="javascript">

		$(document).ready(function(){
			$('body').layout({ west__size: 185 });
			queryDeviceList();
			queryDeptTreeDaTa();
		});

		  var editFlag = [[${@permissionService.hasPermi('module:cloudCpe:edit')}]];
	        var removeFlag = [[${@permissionService.hasPermi('module:cloudCpe:remove')}]];
	        var prefix = ctx + "module/cloudCpe"
	        

	        function queryDeviceList() {
	        	 var options = {
	 	                url: prefix + "/list",
	 	                createUrl: prefix + "/add",
	 	                updateUrl: prefix + "/edit/{id}",
	 	                removeUrl: prefix + "/remove",
	 	               modalName: "CPE管理",
	 	              search: false,
	 	                columns: [{
	 			            checkbox: true
	 			        },
	 				
	 					{
	 						field : 'dept.deptName', 
	 						title : '企业名称' 
	 					},
	 					{
	 						field : 'cpeName', 
	 						title : 'CPE名称' 
	 					},
	 					{
	 						field : 'sn', 
	 						title : 'SN号' 
	 					},
	 					{
	 						field : 'os', 
	 						title : '系统' 
	 					},
	 					{
	 						field : 'agentVersion', 
	 						title : 'Agent版本' 
	 					},
	 					{
	 						field : 'model', 
	 						title : '型号' 
	 					},
	 					 {
	 			            field: 'status',
	 			            title: '状态',
	 			            align: 'center',
	 			            formatter: function(value, row, index) {
	 			                if (value == '0') {
	 			                    return '<span class="badge badge-danger">红色</span>';
	 			                } else if (value == '1') {
	 			                    return '<span class="badge badge-warning">黄色</span>';
	 			                }else  {
	 			                    return '<span class="badge badge-primary">绿色</span>';
	 			                }
	 			            }
	 			        },
	 					
	 			        {
	 			            title: '操作',
	 			            align: 'center',
	 			            formatter: function(value, row, index) {
	 			            	var actions = [];
	 	                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.deviceId + '\')"><i class="fa fa-remove"></i>删除</a>');
	 							return actions.join('');
	 			            }
	 			        }]
	 	            };
			    $.table.init(options);
			}

	    	

		function queryDeptTreeDaTa()
		{
			// 树结构初始化加载
			var setting = {view:{selectedMulti:false},data:{key:{title:"title"},simpleData:{enable:true}},
				callback:{onClick:function(event, treeId, treeNode){
					tree.expandNode(treeNode);
					$("#deptId").val(treeNode.id);
					$("#parentId").val(treeNode.pId);
					$.table.search($('form').attr('id'));
				}}
			}, tree, loadTree = function(){
				$.get(ctx + "system/dept/treeData", function(data) {
				    tree = $.fn.zTree.init($("#tree"), setting, data); //.expandAll(true);
				    // 展开第一级节点
				    var nodes = tree.getNodesByParam("level", 0);
				    for (var i = 0; i < nodes.length; i++) {
				        tree.expandNode(nodes[i], true, false, false);
				    }
				    // 展开第二级节点
				    nodes = tree.getNodesByParam("level", 1);
				    for (var i = 0; i < nodes.length; i++) {
				        tree.expandNode(nodes[i], true, false, false);
				    }
				}, null, null, "正在加载，请稍后...");
			};loadTree();
			
			$('#btnExpand').click(function() {
				tree.expandAll(true);
			    $(this).hide();
			    $('#btnCollapse').show();
			});
			$('#btnCollapse').click(function() {
				tree.expandAll(false);
			    $(this).hide();
			    $('#btnExpand').show();
			});
			$('#btnRefresh').click(function() {
			    loadTree();
			});
		}

		/*用户管理-企业*/
		function dept() {
			var url = ctx + "system/dept";
			createMenuItem(url, "企业管理");
		}
		
		
		function addPop() {
		    var rows = $.table.selectColumns("cpeId");
		    var url = ctx + 'module/pop?cpeId='+rows;
        	$.modal.openFull("配置Pop信息", url, '1024', '800');

		}
		
		
		function addWan() {
		    var rows = $.table.selectColumns("cpeId");
		    var url = ctx + 'module/wan?cpeId='+rows;
        	$.modal.openFull("配置Wan信息", url, '1024', '800');

		}
		
		
		function addLan() {
		    var rows = $.table.selectColumns("cpeId");
		    var url = ctx + 'module/lan?cpeId='+rows;
        	$.modal.openFull("配置Lan信息", url, '1024', '800');
	}
		
		
		function showDetail(){
		    var rows = $.table.selectColumns("cpeId");
		    var url = ctx + 'module/cloudCpe/cloudCpeDetail?cpeId='+rows;
        	$.modal.openFull("详情", url, '1024', '800');

		}
		
		function addRoute(){
		    var rows = $.table.selectColumns("cpeId");
		    var url = ctx + 'module/route?cpeId='+rows;
        	$.modal.openFull("增加业务路由", url, '1024', '800');

		}
		
		function editQos(){
		    var rows = $.table.selectColumns("cpeId");
		    var url = ctx + 'module/cloudCpe/editQos/'+rows;
        	$.modal.openFull("增加业务路由", url, '1024', '800');

		}
		
		function editWifi(){
		    var rows = $.table.selectColumns("cpeId");
		    var url = ctx + 'module/cloudCpe/editWifi/'+rows;
        	$.modal.openFull("增加业务路由", url, '1024', '800');

		}
		
		

	</script>
</body>
</html>








